//姓名
$(".mr_p_name").hover(function(){
	$(".mr_p_name .mr_edit").removeClass("dn");
},function(){
	$(".mr_p_name .mr_edit").addClass("dn");
});
//姓名编辑
$(".mr_p_name .mr_edit").bind("click",
    function() {
    	$(".mr_p_name").hide();
        $(".mr_name_edit").removeClass("dn");
        $("#nameForm").find("input#mr_name")[0].focus();
        f = !1;
    });
//姓名验证
jQuery.validator.addMethod("truename",
    function(a, b) {
        //var c = /^([a-zA-Z ]+|[一-龥]+)$/;
        var c = /^([a-zA-Z ]+|[\u4e00-\u9fa5]+)$/;
        return this.optional(b) || c.test(a);
    },
    "请输入有效的简称"),
    jQuery.validator.addMethod("truename2",
    function(a, b) {
        var c = /([\xb7`~!@#$^&':;,?~！……&；：。，、？=])/;
        return this.optional(b) || !c.test(a);
    },
    "请输入有效的名字"),
    $("#nameForm").validate({
        rules: {
            mr_name: {
                required: !0,
                truename2: !0,
                rangeLenStr: [1, 15]
            }
        },
        messages: {
            mr_name: {
                required: "必填",
                truename2: "格式错误",
                rangeLenStr: "请输入真实姓名"
            }
        },
        errorPlacement: function(a, b) {
            a.appendTo($(b).parent()),
            $(".c_section span.error").css("margin", "5px 0 10px 138px")
        },
        submitHandler: function(a) {
            c = $('input[name="mr_name"]', a).val();
            params={uid:$.cookie("jrqUid"),nickname:c}
            //params ="uid="+$.cookie("jrqUid")+"&sessionId="+$.cookie("sessionId")+"&user.nickname="+c;
            $(a).find(":submit").val("保存中...").attr("disabled", !0);
            $.ajax({  
     	       type : 'post',  
     	       url : 'user_editUser',  
     	       dataType : 'json',  
     	       data : params,
     	  	   success : function (result) {
     	  	   	   if(result.errcode==0){
     	  	   		   $(".mr_name_edit").addClass("dn");
     	  	   		   $(".mr_p_name").show();
                       $(a).find(":submit").val("保 存").attr("disabled", !1);
                       window.open("resume_index","_top");
     	  	   	   }
     	  	   	   
     	       },  
     	       error : function () {  
     	    	    delayURL("金融圈部分数据失联啦，码农门正抓紧修复！","3","");
     	       		return;
     	       }  
           });
        }
    }),
//取消
$("#nameForm .mr_name_edit .cancel").click(function(){
	$(".mr_name_edit").addClass("dn");
	$(".mr_p_name").show();
	//$("#nameForm .mr_name_edit").addClass("dn");
});
//自我介绍
$(".mr_p_introduce").hover(function(){
	$(".mr_p_introduce .mr_edit").removeClass("dn");
},function(){
	$(".mr_p_introduce .mr_edit").addClass("dn");
});

//自我介绍编辑
$(".mr_p_introduce .mr_edit").bind("click",
    function() {
        $(".mr_p_introduce").hide();
        "0" == $(this).attr("data-type") && $("#mr_intro").val($(".mr_p_introduce .mr_intro").text());
        $(".mr_intro_edit").removeClass("dn");
        $("#mr_intro").focus();
        $("#introduceForm .mroneError").hide();
    }),
    
$(".mr_intro_edit .cancel").bind("click",
    function() {
        $(".mr_p_introduce").show();
        $(".mr_intro_edit").addClass("dn");
    }),
    $("#introduceForm").validate({
        rules: {
        	mr_intro: {
                required: !0,
                rangeLenStr: [4, 40]
            }
        },
        messages: {
        	mr_intro: {
                required: "必填",
                rangeLenStr: "请输4-40个字符的自我介绍"
            }
        },
        errorPlacement: function(a, b) {
            a.appendTo($(b).parent()),
            $(".c_section span.error").css("margin", "5px 0 10px 138px")
        },
        submitHandler: function(a) {
            c = $('input[name="mr_intro"]', a).val();
            params={uid:$.cookie("jrqUid"),intro:c}
            //params ="uid="+$.cookie("jrqUid")+"&sessionId="+$.cookie("sessionId")+"&user.intro="+c;
            $(a).find(":submit").val("保存中...").attr("disabled", !0);
            $.ajax({  
     	       type : 'post',  
     	       url : 'user_editUser',  
     	       dataType : 'json',  
     	       data :  params,
     	  	   success : function (result) {
     	  	   	   if(result.errcode==0){
	     	  	       $(".mr_p_introduce").show();
	     	  	       $(".mr_intro_edit").addClass("dn");
                       $(a).find(":submit").val("保 存").attr("disabled", !1);
                       window.open("resume_index","_top");
     	  	   	   }
     	  	   	   
     	       },  
     	       error : function () {  
     	    	    delayURL("金融圈部分数据失联啦，码农门正抓紧修复！","3","");
     	       		return;
     	       }  
           });
        }
    }),
/*$(".mr_p_name .mr_edit").click(function(){
   	$(".form_wrap #shenfen").attr("value",postionAndCompanyname);
   	$(".form_wrap #mr_year").attr("value",year);
   	if(sex=="男"){
   		$(".mr_man").addClass("active");
   	}else if(sex=="女"){
   		$(".mr_women ").addClass("active");
   	}
   	$(".form_wrap #xl").attr("value",degree);
   	$(".form_wrap #gznx").attr("value",worktime);
   	$(".form_wrap #szcs").attr("value",city);
   	$(".form_wrap #mr_mobile").attr("value",tel);
   	$(".form_wrap #mr_email").attr("value",email);
});*/
//基本信息
$(".mr_p_info").hover(function(){
	$(".mr_p_info .mr_edit").removeClass("dn");
},function(){
	$(".mr_p_info .mr_edit").addClass("dn");
});
//基本信息编辑
$(".mr_p_info .mr_edit").click(function(){
	$(".mr_p_info").hide();
    $("#olinfoForm .mr_info_edit").removeClass("dn");
   	$(".form_wrap #shenfen").attr("value",postionAndCompanyname);
   	$(".form_wrap #mr_year").attr("value",year);
   	if(sex=="男"){
   		$(".mr_man").addClass("active");
   	}else if(sex=="女"){
   		$(".mr_women ").addClass("active");
   	}
   	$(".form_wrap #xl").attr("value",degree);
   	$(".form_wrap #gznx").attr("value",worktime);
   	$(".form_wrap #szcs").attr("value",city);
   	$(".form_wrap #mr_mobile").attr("value",tel);
   	$(".form_wrap #mr_email").attr("value",email);
});
//基本信息保存
$("#olinfoForm").validate({
    rules: {
            mr_mobile: {
                required: !0,
                isMobile: !0,
                maxlength: 11
            },
            mr_email: {
                required: !0,
                email: !0,
                maxlength: 100
            },
        },
        messages: {
            mr_mobile: {
                required: "必填",
                isMobile: "目前仅支持11位有效中国大陆号码",
                maxlength: "目前仅支持11位有效中国大陆号码"
            },
            mr_email: {
                required: "必填",
                email: "请输入正确的邮箱",
                maxlength: "输入100个字符以内的邮箱地址"
            }
        },
        errorPlacement: function(a, b) {
            $(b).data("sns") ? $(b).parent().find("em").addClass("mr_no") : (a.insertAfter($(b).parent()), $(".c_section span.error").css("margin", "5px 0 10px 138px"));
        },
        submitHandler: function(a) {
            var b = $('input[name="shenfen"]', a).val();
            c = $('input[name="mr_year"]', a).val();
            l = $(".mr_year_se span.active em").text(),
            e = $('input[name="xl"]', a).val();
            g = $('input[name="gznx"]', a).val();
            h = $('input[name="szcs"]', a).val();
            i = $('input[name="mr_mobile"]', a).val();
            j = $('input[name="mr_email"]', a).val();
            //alert(b+c+e+g+h+i+j+l);
            //params ="type="+"jiben"+"&sessionId="+$.cookie("sessionId")+"&uid="+$.cookie("jrqUid")+"&jiben.rid="+rid+"&jiben.year="+c+"&jiben.sex="+l+"&jiben.degree="+e+"&jiben.worktime="+g+"&jiben.incity="+h+"&jiben.tel="+i+"&jiben.email="+j+"&jiben.useresume=1";
           // params={uid:$.cookie("jrqUid"),year:c,sex:l,degree:e,worktime}
            params={rid:rid,year:c,sex:l,degree:e,worktime:g,incity:h,tel:i,email:j,flag:2};
            $(a).find(":submit").val("保存中...").attr("disabled", !0);
            $.ajax({  
      	       type : 'post',  
      	       url : 'resume_edit',  
      	       dataType : 'json',  
      	       data :  params,
      	  	   success : function (result) {
      	  		   //alert(result.errcode);
      	  	   	   if(result.errcode==0){
                       $("#olinfoForm .mr_info_edit").addClass("dn");
                       $(".mr_p_info").show();
                       $(a).find(":submit").val("保 存").attr("disabled", !1);
                       window.open("resume_index","_top");
      	  	   	   }
      	  	   	  
      	       },  
      	       error : function () {  
      	    	    delayURL("金融圈接口失联啦，码农门正抓紧修复！","3","");
      	       		return;
      	       }  
      	    });	 
        }    
}),
//基本信息取消
$(".mr_ope #mr_cancel1").click(function(){
	$(".mr_p_info").show();
    $("#olinfoForm .mr_info_edit").addClass("dn");
});
//下拉菜单选择
$(".form_wrap").click(function(){
        $(".form_wrap").removeClass("select_color");
        //$(this).children(".xl_list").removeClass("dn");
        var index = $(this).index();
       	var b = $(this).find(".xl_list");
        b.is(":hidden") && $(this).addClass("select_color");
        b.toggle();
/*        if(index==8){
			$(this).children(".xl_list").removeClass("dn");
        }else{
       	var b = $(this).find(".xl_list");
        b.is(":hidden") && $(this).addClass("select_color");
        b.toggle();
        }*/
});
//城市选择
/*$(".mr_selCity ul li span").click(function(){
	$(".mr_selCity ul li ul").addClass("dn");
    $("#szcs").val($(this).text());
    $(this).next("ul").removeClass("dn");
    $(this).parent().parent().parent().parent().removeClass("dn");
    //var c = $(this).find(".reset");
    //c.is(":hidden") && $(this).addClass("select_color");
});
$(".mr_selCity ul li ul li").click(function(){
    $("#szcs").val($(this).text());
	//$(this).parent().parent().parent().parent().parent().hide();
});*/
//男女选择
$(".mr_man").click(function(){
	$(".mr_man").addClass("active");
	$(".mr_women").removeClass("active");
});
$(".mr_women").click(function(){
	$(".mr_women").addClass("active");
	$(".mr_man").removeClass("active");
});



$(".ul_year").delegate("li", "click",
function() {
    $("#mr_year").val($(this).text());
    //$(this).parent().parent().hide();
    $(".select_color").removeClass("select_color");
});

$(".ul_xl").delegate("li", "click",
function() {
    $("#xl").val($(this).text());
    //$(this).parent().parent().hide(),
    $(".select_color").removeClass("select_color");
});
$(".ul_gznx").delegate("li", "click",
function() {
    var a = $(this).text();
    if ($("#gznx").val(a), "应届毕业生" == $.trim(a)) {
        var b = $(".ul_shenfen li[data-id = '1']");
        0 != b.length && ($("#shenfen").val(b.text()), globals.personIdFlag = "1")
    } else {
        var c = $(".ul_shenfen li[data-id = '2']");
        0 != c.length && ($("#shenfen").val(c.text()), globals.personIdFlag = "2")
    }
    //$(this).parent().parent().hide();
    $(".select_color").removeClass("select_color");
});


//工作经历
var flag;
var url;
var params
//工作经历添加
$("#workExperience .mr_moudle_head .mr_head_r").click(function(){
	if(gzjl_counts>=3){
		delayURL("至多只能添加3条工作经历", "3", "");
		return;
	}else{
		//$("#workExperience").hide();
		$(".jobExpForm").removeClass("dn");
		$("#gzjl_delete").hide();
		flag = "workExperienceAdd";
	}
});
//工作经历取消
$("#addJobForm .mr_add_work .mr_ope .mr_cancel").click(function(){
	//$("#workExperience").hide();
	$(".jobExpForm").addClass("dn");
	$(".appendGzHtml").show();
});
//工作经历保存
$("#addJobForm").validate({
    rules: {
    			companyName: {
                required: !0,
                maxlength: 20
            },
            	positionName: {
            	required: !0,
            	maxlength: 10
		}
        },
        messages: {
        	companyName: {
                required: "必填",
                maxlength: "请输入20个字符以内的公司名称"
            },
            positionName: {
	        	required: "必填",
	        	maxlength: "请输入10个字符以内的职位名称"
	        }
        },
        submitHandler: function(a) {
            d = $("#mr_expid").val(),
            e = $("img.logo_u", a).attr("src");
            f = $('input[name="companyName"]', a).val();
            g = $('input[name="positionName"]', a).val();
            h = $('input[id="startTime"]', a).val();
            i = $('input[id="endTime"]', a).val();
            //j = $("#jobContent").val();
            j = UE.getEditor('editor1').getContent();
            //j = tinyMCE.get("upjobContent").getContent(),
            k = $("input[name='companyLogoHide']", a).val(),
            l = !1;
            /*alert(h+"(("+i);//可以测试是否获取到数据值*/
            if(flag=="workExperienceAdd"){
            	url = "resumepractice_addPractice";
            	var params={rid:rid,uid:$.cookie("jrqUid"),corpname:f,position:g,startdate:h,enddate:i,descr:j};
            	//var params = {rid:rid,uid:$.cookie("jrqUid"),}
            	//params ="type="+"gongzuo"+"&sessionId="+$.cookie("sessionId")+"&uid="+ $.cookie("jrqUid")+"&gongzuo.rid="+rid+"&gongzuo.corpname="+f+"&gongzuo.position="+g+"&gongzuo.startdate="+h+"&gongzuo.enddate="+i+"&gongzuo.descr="+j;
            }else if(flag=="workExperienceEadit"){
            	url = "resumepractice_editPractice";
            	var params={rid:rid,uid:$.cookie("jrqUid"),corpname:f,position:g,startdate:h,enddate:i,descr:j,prid:gzjl_prid};
            	//params ="type="+"gongzuo"+"&sessionId="+$.cookie("sessionId")+"&uid="+ $.cookie("jrqUid")+"&gongzuo.prid="+gzjl_prid+"&gongzuo.corpname="+f+"&gongzuo.position="+g+"&gongzuo.startdate="+h+"&gongzuo.enddate="+i+"&gongzuo.descr="+j;
            }
            $(a).find(":submit").val("保存中...").attr("disabled", !0);
            $.ajax({  
       	       type : 'post',  
       	       url : url,  
       	       dataType : 'json',  
       	       data : params,
       	  	   success : function (result) {
      	  	   	   if(result.errcode==0){
                       $("#addJobForm .mr_add_work").addClass("dn");
                       $(a).find(":submit").val("保 存").attr("disabled", !1);
                       $("#workExperience .mr_w604 .list_show").show();
                       //$(".mr_content").show();
                       window.open("resume_index","_top");
      	  	   		   //history.go(0);
      	  	   	   }
       	       },  
       	       error : function () {  
       	    	    delayURL("金融圈部分数据失联啦，码农门正抓紧修复！","3","");
       	       		return;
       	       }  
       	    });	 
        }    
});
/*$("#addJobForm .mr_add_work .mr_sta_time").click(function(){
	$(this).children(".mr_calendar_ym").removeClass("dn");
	
});
$("#addJobForm .mr_add_work .mr_sta_time .mr_calendar_ym ul li").click(function(){
	
});*/
/*//工作经历编辑
$("#gzjl_eadit").click(function(){
	$("#addJobForm").removeClass("dn");
	$("#workExperience .mr_w604 .list_show").hide();
	flag = "workExperienceEadit";
    //$(this).parents(".mr_jobe_list").next().attr("id", "upJobForm");
	$(".mr_input_div .companyName").attr("value",companyname);
	$(".mr_input_div .autoPosition").attr("value",postion);
	$(".mr_sta_time .mr_btn").attr("value",start);
	$(".mr_end_time .mr_btn").attr("value",end);
	
});*/
//工作经历删除
$("#gzjl_delete").click(function(){
	$(".mr_delete_pop").removeClass("dn");
});
$("#gzjl_delete_cancel").click(function(){
	$(".mr_delete_pop").addClass("dn");
});
$("#gzjl_delete_sure").click(function(){
	
	var params = {prid:gzjl_prid};
		
		//"type="+"gongzuo"+"&sessionId="+$.cookie("sessionId")+"&uid="+ $.cookie("jrqUid")+"&gongzuo.prid="+prid;
	$.ajax({  
	       type : 'post',  
	       url : 'resumepractice_delPractice',  
	       dataType : 'json',  
	       data :  params,
	  	   success : function (result) {
	  	   	   if(result.errcode==0){
                $("#addJobForm .mr_add_work").addClass("dn");
                $("#workExperience .mr_w604 .list_show").show();
                window.open("resume_index","_top");
	  	   	   }
	  	   	   if(result.errcode==40014){
	  	   		   delayURL("工作经历删除失败！","3","");
	  	   		   $("#workExperience .mr_w604 .list_show").hide();
	  	   	   }
	  	   	   
	       },  
	       error : function () {  
	    	    delayURL("金融圈部分数据失联啦，码农门正抓紧修复！","3","");
	       		return;
	       }  
	    });	
});


//教育经历
var flag;
var url;
var params;
//教育经历添加
$("#jyjl_add").click(function(){
	if(jyjl_counts>=3){
//		alert("至多只能添加3条教育经历");
		return;
	}else{
		$("#addEduForm").removeClass("dn");
		$("#educationalBackground .mr_w604 .list_show").hide();
		$("#jyjl_delete").hide();
		flag="eduAdd";
	}
});
//教育经历取消
$("#jyjl_cancel").click(function(){
	//$("#workExperience").hide();
	$("#addEduForm").addClass("dn");
	$(".appendJyHtml").show();
});
//教育经历保存
$("#addEduForm").validate({
    rules: L.rules,
    messages: L.messages,
    errorPlacement: function(a, b) {
        L.errorPlacement(a, b)
    },
    submitHandler: function(a) {
        c = $('input[name="schoolName"]', a).val();
        d = $('input[name="eduPositionName"]', a).val();
        e = $('input[name="degree_val"]', a).val();
        f = $('input[name="graduate"]', a).val();
        if(flag=="eduAdd"){
        	url = "resumeedu_addEdu";
        	params={rid:rid,uid:$.cookie("jrqUid"),schoolname:c,degree:e,majorname:d,enddate:f};
        	/*params ="type="+"jiaoyu"+"&sessionId="+$.cookie("sessionId")+"&uid="+ $.cookie("jrqUid")+"&jiaoyu.rid="+rid+"&jiaoyu.schoolname="+c+"&jiaoyu.majorname="+d+"&jiaoyu.degree="+e+"&jiaoyu.enddate="+f+"&jiben.useresume=1";*/
        }else if(flag=="eduEadit"){
        	url = "resumeedu_editEdu";
        	params={rid:rid,uid:$.cookie("jrqUid"),schoolname:c,degree:e,majorname:d,enddate:f,edid:jyjl_eduid};
        	/*params ="type="+"jiaoyu"+"&sessionId="+$.cookie("sessionId")+"&uid="+ $.cookie("jrqUid")+"&jiaoyu.edid="+jyjl_eduid+"&jiaoyu.schoolname="+c+"&jiaoyu.majorname="+d+"&jiaoyu.degree="+e+"&jiaoyu.enddate="+f+"&jiben.useresume=1";*/
        }
        $(a).find(":submit").val("保存中...").attr("disabled", !0),
        $.ajax({  
   	       type : 'post',  
   	       url : url,  
   	       dataType : 'json',  
   	       data : params,
   	  	   success : function (result) {
   	  	   	   if(result.errcode==0){
   	  	   		   $("#addEduForm .mr_add_work").addClass("dn");
                   $(a).find(":submit").val("保 存").attr("disabled", !1);
                   //$(".mr_content").show();
                   window.open("resume_index","_top");
   	  	   	   }
   	  	   	  
   	       },  
   	       error : function () {  
   	    	    delayURL("金融圈部分数据失联啦，码农门正抓紧修复！","3","");
   	       		return;
   	       }  
   	    });	 
    }
});
/*//教育经历编辑
$("#jyjl_eadit").click(function(){
	$("#addEduForm").removeClass("dn");
	$("#educationalBackground .mr_w604 .list_show").hide();
	flag = "eduEadit";
    //$(this).parents(".mr_jobe_list").next().attr("id", "upJobForm");
	//alert(schoolName+eduPositionName+degree_val+graduate);
	$("#schoolName").attr("value",schoolName);
	$("#eduPositionName").attr("value",eduPositionName);
	$("#degree_val").attr("value",degree_val);
	$("#graduate").attr("value",graduate);
	
});*/

//教育经历下拉框
$("#degree_click").click(function(){
	//$(this).children(".xl_list").removeClass("dn");
	$("#addEduForm .mr_add_work .mr_time_area .mr_sta_time").removeClass("select_color");
   	var b = $(this).find(".xl_list");
    b.is(":hidden") && $(this).addClass("select_color");
    b.toggle();
});
$("#degree_click .xl_list ul li").click(function(){
	 $("#degree_val").val($(this).text());
});

$("#graduate_click").click(function(){
	//$(this).children(".xl_list").removeClass("dn");
	$("#addEduForm .mr_add_work .mr_time_area .mr_timed_div").removeClass("select_color");
	var b = $(this).find(".xl_list");
	b.is(":hidden") && $(this).addClass("select_color");
	b.toggle();
});
$("#graduate_click .xl_list ul li").click(function(){
	$("#graduate").val($(this).text());
});

//教育经历删除
$("#jyjl_delete").click(function(){
	$(".mr_delete_pop").removeClass("dn");
});
$("#jyjl_delete_cancel").click(function(){
	$(".mr_delete_pop").addClass("dn");
});
$("#jyjl_delete_sure").click(function(){
	var params ={edid:jyjl_eduid}  //教育经历的edid
	$.ajax({  
	       type : 'post',  
	       url : 'resumeedu_delEdu',  
	       dataType : 'json',  
	       data : params,
	  	   success : function (result) {
	  	   	   if(result.errcode==0){
   	  	   		   $("#addEduForm .mr_add_work").addClass("dn");
                   window.open("resume_index","_top");
	  	   	   }
	  	   	   if(result.errcode==40014){
	  	   		   delayURL("工作经历删除失败！","3","");
	  	   		   $("#educationalBackground .mr_w604 .list_show").show();
	  	   	   }
	  	   	   
	       },  
	       error : function () {  
	    	    delayURL("金融圈接口失联啦，码农门正抓紧修复！","3","");
	    	    $("#educationalBackground .mr_w604 .list_show").hide();
	       		return;
	       }  
	    });	
});

//自我介绍编辑
$("#zwjs_eadit").click(function(){
	$("#upSelfForm").removeClass("dn");
	$(".self_des_list").hide();
	//$("#selfdc_customCon").val(selfdc);
	UE.getEditor('editor2').setContent(selfdc);
    //$(this).parents(".mr_jobe_list").next().attr("id", "upJobForm");
	//alert(schoolName+eduPositionName+degree_val+graduate);
	
});
//自我介绍取消
$("#zwms_cancel").click(function(){
	$("#upSelfForm").addClass("dn");
	$(".self_des_list").show();
	//$(this).parents(".mr_jobe_list").next().attr("id", "upJobForm");
	//alert(schoolName+eduPositionName+degree_val+graduate);
	
});
//自我介绍验证保存
$("#upSelfForm").validate({
    rules: {
    	selfdc_customCon: {
            required: !0,
            rangeLenStr: [10, 200]
        }
    },
    messages: {
    	selfdc_customCon: {
            required: "必填",
            rangeLenStr: "请输10-200个字符的自我描述"
        }
    },
    errorPlacement: function(a, b) {
        a.appendTo($(b).parent()),
        $(".c_section span.error").css("margin", "5px 0 10px 138px")
    },
    submitHandler: function(a) {
    	//var s = $("#selfdc_customCon").val();
/*        function getContent() {
            var arr = [];
            arr.push("使用editor.getContent()方法可以获得编辑器的内容");
            arr.push("内容为：");
            arr.push(UE.getEditor('editor').getContent());
            alert(arr.join("\n"));
        }*/
        var s = UE.getEditor('editor2').getContent();
//        params ="type="+"jiben"+"&sessionId="+$.cookie("sessionId")+"&uid="+$.cookie("jrqUid")+"&jiben.rid="+rid+"&jiben.selfdc="+s+"&jiben.useresume=1";
        params={rid:rid,selfdc:s,flag:1};//flag=1，代表要修改自我描述，flag=2,代表修改基本信息
        $(a).find(":submit").val("保存中...").attr("disabled", !0);
        $.ajax({  
   	       type : 'post',  
   	       url : 'resume_edit',  
   	       dataType : 'json',  
   	       data : params,
   	  	   success : function (result) {
   	  	   	   if(result.errcode==0){
                    $("#olinfoForm .mr_info_edit").addClass("dn");
                    $(".mr_p_info").show();
                    $(a).find(":submit").val("保 存").attr("disabled", !1);
                    window.open("resume_index","_top");
   	  	   	   }
   	  	   	  
   	       },  
   	       error : function () {  
   	    	    delayURL("金融圈接口失联啦，码农门正抓紧修复！","3","");
   	       		return;
   	       }  
   	    });	 
    }
}),
//求职标记
$(".ul_self_state li").click(function(){
	$("#self_state").attr("value",$(this).text());
	var nowstatu = $(this).text();
	//params ="type="+"jiben"+"&sessionId="+$.cookie("sessionId")+"&uid="+$.cookie("jrqUid")+"&jiben.rid="+rid+"&jiben.nowstatu="+nowstatu;
	
	$.ajax({  
	       type : 'post',  
	       url : 'resume_edit',  
	       dataType : 'json',  
	       data : params,
	  	   success : function (result) {
	  	   	   if(result.errcode==0){
                 window.open("./myresume.jsp#self_state","_top");
	  	   	   }
	  	   	  
	       },  
	       error : function () {  
	    	    delayURL("金融圈接口失联啦，码农门正抓紧修复！","3","");
	       		return;
	       }  
	    });	
});
//右侧悬停
var c = $(".mr_myresume_r .scroll_fix").offset();
$(window).scroll(function() {
    var a = $(window).scrollTop();
    c && c.top <= a ? $(".mr_myresume_r .scroll_fix").addClass("mr_myresume_r_fix") : $(".mr_myresume_r .scroll_fix").removeClass("mr_myresume_r_fix");
});
//右侧导航菜单
$(".mr_module ul li").click(function(){
	$(".mr_module ul li").removeClass("active");
	$(this).addClass("active");
});

//上传图片
/*$("#headPic").click(function() {
	ajaxFileUpload();
});*/
var fileFlag;
$("#headPic").change(function(){
	var objUrl;
	if(isIE = navigator.userAgent.indexOf("MSIE 8")!=-1) { 
		objUrl=1;
	}else{
		objUrl = getObjectURL(this.files[0]) ;
		if(this.files[0].size/1024>500){
			delayURL("图片不大于500KB。", "3", "");
			return;
		}
	}
	var headPic = $("#headPic").val();
	var extStart=headPic.lastIndexOf(".");
    var ext=headPic.substring(extStart,headPic.length).toUpperCase();
    if(ext!=".BMP"&&ext!=".PNG"&&ext!=".GIF"&&ext!=".JPG"&&ext!=".JPEG"){
    	delayURL("图片限于bmp,png,gif,jpeg,jpg格式", "3", "");
    	return;
    }
	if(objUrl!=null) {
		if(objUrl!=1){
			$("#userpic").attr("src", objUrl);
		}
		if(headPicFlag==1){
			deleteFile(headPicName,0);
			params ="uid="+$.cookie("jrqUid")+"&user.portrait="+0+"&sessionId="+$.cookie("sessionId");//0代表空
            $.ajax({  
        	       type : 'post',  
        	       url : 'updateUserInfo.action',  
        	       dataType : 'json',  
        	       data :  {"params":params},
        	  	   success : function (result) {
        	  	   	   if(result.errcode==0){
        	  	   		   ajaxFileUpload(0);
        	  	   	   }
        	       },  
        	       error : function () {  
        	       		return;
        	       }  
           });
		}else{
			ajaxFileUpload(0);
		}
	}
}) ;
function deleteFile(fileName,fileFlag) {
    if(fileFlag==0){
    	fileName = headPicName;
    }else if(fileFlag==1){
    	fileName = filesName;
    }
    $.ajax({  
	       type : 'post',  
	       url : 'deleteFile.action',  
	       dataType : 'json',  
	       data :  {"fileName":fileName,"fileFlag":fileFlag},
	  	   success : function (result) {
	  	   	   if(result.errcode==0){
	  	   	   }
	       },  
	       error : function () {  
	       		return;
	       }  
   });
}
function getObjectURL(file) {
	var url = null ; 
	if (window.createObjectURL!=undefined) { // basic
		url = window.createObjectURL(file) ;
	} else if (window.URL!=undefined) { // mozilla(firefox)
		url = window.URL.createObjectURL(file) ;
	} else if (window.webkitURL!=undefined) { // webkit or chrome
		url = window.webkitURL.createObjectURL(file) ;
	}
	return url ;
}
function ajaxFileUpload(fileFlag) {
    // 开始上传文件时显示一个图片
    $("#wait_loading").ajaxStart(function() {
        $(this).show();
    // 文件上传完成将图片隐藏起来
    }).ajaxComplete(function() {
        $(this).hide();
    });
    if(fileFlag==0){
    	fileName = headPicName;
    	fileElementId = "headPic";
    }else if(fileFlag==1){
    	fileName = filesName;
    	fileElementId = "fileInline";
    }
    //var elementIds=["flag"]; //flag为id、name属性名
    $.ajaxFileUpload({
        url: 'UploadFile.action', 
        type: 'post',
        data: {"fileName":fileName,"fileFlag":fileFlag},
        dataType : 'text',  //返回值类型，一般设置为json、application/json
        //secureuri: false, //一般设置为false
        fileElementId: fileElementId, // 上传文件的id、name属性名
        //elementIds: elementIds, //传递参数到服务器
        success: function(result){  
        	result = JSON.parse(result);
            if(result.errcode==0){
            	if(fileFlag==0){
            		params ="uid="+$.cookie("jrqUid")+"&sessionId="+$.cookie("sessionId")+"&user.portrait="+result.imgSrc1;
            		url = "updateUserInfo.action";
            	}
            	if(fileFlag==1){
            		params ="type="+"jiben"+"&uid="+$.cookie("jrqUid")+"&sessionId="+$.cookie("sessionId")+"&jiben.rid="+rid+"&jiben.attachment="+result.fileSrc;
            		//alert(params);
            		url = "updateResume.action";
            	}
                $.ajax({  
            	       type : 'post',  
            	       url : url,  
            	       dataType : 'json',  
            	       data :  {"params":params},
            	  	   success : function (result) {
            	  	   	   if(result.errcode==0){
            	  	   		   window.open("./myresume.jsp","_top");
            	  	   	   }
            	       },  
            	       error : function () {  
            	    	    delayURL("上传失败,请刷新页面后再次上传！","3","");
            	       		return;
            	       }  
               });
            }else if(result.errcode=="40003"){
            	delayURL("图片上传失败！","3","");
            }
        },
        error: function(result){ 
        	return;
        	//delayURL("图片上传失败！","3","");
        }
    });
    //return false;
}

//上传简历
$("#fileInline").change(function(){
	var objUrl;
	if(isIE = navigator.userAgent.indexOf("MSIE 8")!=-1) { 
		objUrl=1;
	}else{
		objUrl = getObjectURL(this.files[0]) ;
		if(this.files[0].size/1024>3000){
			delayURL("简历文件不大于3M。", "3", "");
			return;
		}
	}

	var fileInline = $("#fileInline").val();
	var extStart=fileInline.lastIndexOf(".");
    var ext=fileInline.substring(extStart,fileInline.length).toUpperCase();
    if(ext!=".txt"&&ext!=".doc"&&ext!=".docx"&&ext!=".pdf"&&ext!=".ppt"&&ext!=".wps"&&ext!=".TXT"&&ext!=".DOC"&&ext!=".DOCX"&&ext!=".PDF"&&ext!=".PPT"&&ext!=".WPS"){
    	delayURL("简历文件类型限于txt,doc,docx,pdf,ppt,wps", "3", "");
    	return;
    }
    if(objUrl!=null) {
		//$(".uoload_inline").text(objUrl);
		if(fileFlag==1){
			deleteFile(filesName,1);
			params ="type="+"jiben"+"&sessionId="+$.cookie("sessionId")+"&uid="+$.cookie("jrqUid")+"&jiben.rid="+rid+"&jiben.attachment="+0;
            $.ajax({  
        	       type : 'post',  
        	       url : 'updateResume.action',  
        	       dataType : 'json',  
        	       data :  {"params":params},
        	  	   success : function (result) {
        	  	   	   if(result.errcode==0){
        	  	   		   ajaxFileUpload(1);
        	  	   	   }
        	       },  
        	       error : function () {  
        	       		return;
        	       }  
           });
		}else{
			ajaxFileUpload(1);
		}
	}
}) ;

//文件下载
$(".mr_up_main a").click(function(){
	window.open('./download.jsp?fileName='+filesName,'_top');
});

//文件删除
$(".mr_uploaded").on("click", "a.mr_del",
    function() {
		params ="type="+"jiben"+"&sessionId="+$.cookie("sessionId")+"&uid="+$.cookie("jrqUid")+"&jiben.rid="+rid+"&jiben.attachment="+0;	
        confirm("你确定要删除该附件吗？删除后你设置的默认投递简历也将失效") &&  $.ajax({  
 	       type : 'post',  
	       url : 'updateResume.action',  
	       dataType : 'json',  
	       data :  {"params":params},
	  	   success : function (result) {
	  	   	   if(result.errcode==0){
	  	   		   deleteFile(filesName,1);
	  	   		   $(".mr_uploaded").hide();
	  	   		   $(".mr_upload").show();
	  	   	   }else{
//	  	   		   alert("文件删除失败!");
	  	   	   }
	       },  
	       error : function () {  
	       		return;
	       }  
   });
});
//默认投递状态
$(".set_default_wrap span").click(function(){
	$(".set_default_wrap .xl_list").removeClass("dn");
	var params ="type="+"jiben"+"&sessionId="+$.cookie("sessionId")+"&uid="+$.cookie("jrqUid")+"&jiben.rid="+rid+"&jiben.useresume="+1;
	$.ajax({  
       type : 'post',  
       url : 'updateResume.action',  
       dataType : 'json',  
       data :  {"params":params},
  	   success : function (result) {
  	   	   if(result.errcode==0){
  	   	   }
  	   	   //location.reload(true);
  	   	  
       },  
       error : function () {  
    	    delayURL("金融圈接口失联啦，码农门正抓紧修复！","3","");
    	    //location.reload(true);
       		return;
       }  
    });
});
$(".ul_resume_type li").click(function(){
	$(".set_default_wrap .xl_list").addClass("dn");
	$("#default_resume").attr("value",$(this).text());
	var useresume=1;
	if($("#default_resume").val()=="默认投递：附件简历")
	{
		useresume=2;
	}
	var params ="type="+"jiben"+"&sessionId="+$.cookie("sessionId")+"&uid="+$.cookie("jrqUid")+"&jiben.rid="+rid+"&jiben.useresume="+useresume;
	$.ajax({  
       type : 'post',  
       url : 'updateResume.action',  
       dataType : 'json',  
       data :  {"params":params},
  	   success : function (result) {
  	   	   if(result.errcode==0){
  	   	   }
  	   	   //location.reload(true);
  	   	  
       },  
       error : function () {  
    	    delayURL("金融圈接口失联啦，码农门正抓紧修复！","3","");
    	    //location.reload(true);
       		return;
       }  
    });
});
//简历预览下载
$("#dwnWord").click(function(){ 
	$.ajax({  
	       type : 'post',  
	       url : 'exportWord.action',  
	       dataType : 'json',  
	       data :  {"jiben":JSON.stringify(results.jiben),"gongzuo":JSON.stringify(results.gongzuo),"jiaoyu":JSON.stringify(results.jiaoyu),"userName":userName,"userIntro":userIntro},
	  	   success : function (result) {
	  		   if(result.errcode==0){
	  			   window.open('./download.jsp?fileName='+"preview.doc",'_top');
	  		   }else{
	  			 delayURL("简历下载失败，请稍后再试！", "3", "");
	  		   }
	       },  
	       error : function () {  
	       		return;
	       }  
	});
});
//城市和时间函数
try {
    var baseInfoCityWrapper = new components.CityWrapper({
            container: $("#olinfoForm .city_s"),
            onchange: function(value, container) {
                    container.find(".error").hide()
            },
            beforeShown: function(container, instance) {
                    $(document).trigger("click");
                    $(".select_color").removeClass("select_color");
                    container.addClass("select_color")
            },
            afterHide: function(container, instance) {
                    container.removeClass("select_color")
            }
    });
    var expJobCityWrapper = new components.CityWrapper({
            container: $("#upExpJobForm .city_s"),
            onchange: function(value, container) {
                    container.find(".error").hide()
            },
            beforeShown: function(container, instance) {
                    $(document).trigger("click");
                    $(".select_color").removeClass("select_color");
                    container.addClass("select_color")
            },
            afterHide: function(container, instance) {
                    container.removeClass("select_color")
            }
    });
    var unbaseInfoCityWrapper = new components.CityWrapper({
            container: $("#infoForm .city_s"),
            onchange: function(value, container) {
                    container.find(".error").hide()
            },
            beforeShown: function(container, instance) {
                    $(document).trigger("click");
                    $(".select_color").removeClass("select_color");
                    container.addClass("select_color")
            },
            afterHide: function(container, instance) {
                    container.removeClass("select_color")
            }
    })
} catch(e) {}
try {
    var workExpDateStarter = new components.CalendarWrapper({
            container: $("#addJobForm").find(".mr_timed_div:first"),
            onchange: function(value, container) {
                    workExpDateEnder.setLeftBoundary(value);
                    container.find(".error").hide()
            },
            beforeShown: function(container, instance) {
                    workExpDateEnder.hide();
                    $(".select_color").removeClass("select_color");
                    container.addClass("select_color");
                    container.css("zIndex", "2");
                    container.siblings("div:last").css("zIndex", "1")
            },
            afterHide: function(container, instance) {
                    container.removeClass("select_color");
                    container.css("zIndex", "auto");
                    container.siblings("div:last").css("zIndex", "auto")
            }
    });
    var workExpDateEnder = new components.CalendarWrapper({
            container: $("#addJobForm").find(".mr_timed_div:last"),
            onchange: function(value, container) {
                    workExpDateStarter.setRightBoundary(value);
                    container.find(".error").hide()
            },
            beforeShown: function(container, instance) {
                    workExpDateStarter.hide();
                    $(".select_color").removeClass("select_color");
                    container.addClass("select_color")
            },
            afterHide: function(container, instance) {
                    container.removeClass("select_color")
            },
            has2Today: true
    });
    var workExpUpDateStarter, workExpUpDateEnder
} catch(e) {}